home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Source / Asm / Blitter / OBJ_RamboWorm.s < prev    next >
Encoding:
Text File  |  1998-03-15  |  6.0 KB  |  280 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This example blits a Worm from an IFF file onto a double buffered screen.
  3. ;The RESTORE mode is used to put the background back.
  4. ;
  5. ;All structures defined externally.
  6.  
  7.     INCDIR    "GMSDev:Includes/"
  8.     INCLUDE    "dpkernel/dpkernel.i"
  9.     INCLUDE    "files/objects.i"
  10.     INCLUDE    "modules/objects.i"
  11.  
  12.     SECTION    "Demo",CODE
  13.  
  14. ;===========================================================================;
  15. ;                             INITIALISE DEMO
  16. ;===========================================================================;
  17.  
  18.     STARTDPK
  19.  
  20. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  21.     move.l    DPKBase(pc),a6
  22.     lea    OBJFileName(pc),a0    ;a0 = Object FileName.
  23.     moveq    #ID_OBJECTFILE,d0    ;d0 = Object DataBase.
  24.     CALL    Load
  25.     move.l    d0,ObjectData
  26.     beq    .Exit
  27.  
  28.     ;Open the objects module.
  29.  
  30.     lea    ObjModTags(pc),a0    ;a0 = Module tags.
  31.     sub.l    a1,a1    ;a1 = No container.
  32.     CALL    Init    ;>> = Initialise Cards Interface.
  33.     tst.l    d0    ;d0 = Check for error.
  34.     beq    .Exit    ;>> = Error, exit.
  35.     move.l    d0,a0    ;a0 = Card module.
  36.     move.l    MOD_ModBase(a0),OBJBase    ;ma = Store jump table.
  37.  
  38.     move.l    OBJBase(pc),a6
  39.     move.l    ObjectData(pc),a0    ;a0 = Object Base.
  40.     lea    Objects(pc),a1    ;a1 = A list of objects to get.
  41.     CALL    PullObjectList    ;>> = Get our objects.
  42.     tst.l    d0    ;d0 = Check for error.
  43.     bne    .Exit    ;>> = Quit if error.
  44.  
  45. ;---------------------------------------------------------------------------;
  46.  
  47.     move.l    DPKBase(pc),a6
  48.     lea    BackgroundFile(pc),a0
  49.     moveq    #ID_PICTURE,d0
  50.     CALL    Load
  51.     move.l    d0,PIC_Background
  52.     beq    .Exit
  53.  
  54.     moveq    #ID_SCREEN,d0
  55.     CALL    Get
  56.     move.l    d0,Screen
  57.     beq    .Exit
  58.  
  59.     ;Copy picture details to screen.
  60.  
  61.     move.l    PIC_Background(pc),a0
  62.     move.l    PIC_Bitmap(a0),a2
  63.     move.l    Screen(pc),a1
  64.     move.l    #SCR_DBLBUFFER,GS_Attrib(a1)
  65.     CALL    CopyStructure
  66.  
  67.     ;Initialise the screen.
  68.  
  69.     move.l    Screen(pc),a0    ;Initialise the screen.
  70.     sub.l    a1,a1
  71.     CALL    Init
  72.     tst.l    d0
  73.     beq.s    .Exit
  74.  
  75.     move.l    PIC_Background(pc),a0
  76.     move.l    PIC_Bitmap(a0),a0
  77.     move.l    Screen(pc),a1
  78.     move.l    GS_Bitmap(a1),a1
  79.     CALL    Copy
  80.  
  81.     move.l    BLTBase(pc),a6
  82.     move.l    Screen(pc),a0
  83.     moveq    #BUFFER2,d0
  84.     moveq    #BUFFER1,d1
  85.     CALL    bltCopyBuffer
  86.  
  87. ;---------------------------------------------------------------------------;
  88. ;Initialise the restore object.
  89.  
  90.     move.l    DPKBase(pc),a6
  91.     lea    RestoreTags(pc),a0
  92.     move.l    Screen(pc),a1
  93.     CALL    Init
  94.     tst.l    d0
  95.     beq.s    .Exit
  96.  
  97. ;---------------------------------------------------------------------------;
  98. ;Load the bob file in.  This contains the graphics data that we are
  99. ;going to draw to the screen.
  100.  
  101.     move.l    BOB_Rambo(pc),a0
  102.     move.l    Screen(pc),a1
  103.     CALL    Init
  104.     tst.l    d0
  105.     beq.s    .Exit
  106.  
  107. ;---------------------------------------------------------------------------;
  108. ;Load sounds and initialise joydata object.
  109.  
  110.     move.l    SND_Rambo(pc),a0
  111.     sub.l    a1,a1
  112.     CALL    Init
  113.     tst.l    d0
  114.     beq.s    .Exit
  115.  
  116.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  117.     CALL    Get
  118.     move.l    d0,JoyData
  119.     beq.s    .Exit
  120.     move.l    d0,a0    ;Initialise the joydata structure.
  121.     sub.l    a1,a1
  122.     CALL    Init
  123.     tst.l    d0
  124.     beq.s    .Exit
  125.  
  126. ;---------------------------------------------------------------------------;
  127. ;Display our screen and start the demo.
  128.  
  129.     move.l    Screen(pc),a0
  130.     CALL    Display
  131.  
  132.     bsr.s    Main
  133.  
  134. ;---------------------------------------------------------------------------;
  135. ;Free the allocations.
  136.  
  137. .Exit    move.l    DPKBase(pc),a6
  138.     move.l    JoyData(pc),a0
  139.     CALL    Free
  140.     move.l    SND_Rambo(pc),a0
  141.     CALL    Free
  142.     move.l    BOB_Rambo(pc),a0
  143.     CALL    Free
  144.     move.l    Restore(pc),a0
  145.     CALL    Free
  146.     move.l    PIC_Background(pc),a0
  147.     CALL    Free
  148.     move.l    Screen(pc),a0
  149.     CALL    Free
  150.     move.l    ObjectData(pc),a0
  151.     CALL    Free
  152.     move.l    ObjModule(pc),a0
  153.     CALL    Free
  154.     MOVEM.L    (SP)+,A0-A6/D1-D7
  155.     moveq    #ERR_OK,d0
  156.     rts
  157.  
  158. ;===========================================================================;
  159. ;                                MAIN LOOP
  160. ;===========================================================================;
  161.  
  162. SPEED    =    5
  163. FIRESPEED =    0
  164.  
  165. Main:    moveq    #$00,d7
  166.  
  167. .Loop    move.l    DPKBase(pc),a6
  168.     move.l    Restore(pc),a0    ;a0 = Restore.
  169.     CALL    Activate    ;>> = Restore the backgrounds.
  170.  
  171.     move.l    BOB_Rambo(pc),a0
  172.     CALL    Draw    ;>> = Blit the bob.
  173.  
  174.     move.l    SCRBase(pc),a6
  175.     CALL    scrWaitAVBL    ;>> = Wait for VBL.
  176.     move.l    Screen(pc),a0
  177.     CALL    scrSwapBuffers
  178.  
  179.     addq.w    #1,d7
  180.  
  181.     move.l    DPKBase(pc),a6
  182.     move.l    BOB_Rambo(pc),a1
  183.     tst.b    FireState
  184.     bne.s    .FireOn
  185.  
  186.     cmp.w    #SPEED,d7
  187.     ble.s    .Move
  188.     moveq    #$00,d7
  189.     addq.w    #1,BOB_Frame(a1)
  190.     cmp.w    #9,BOB_Frame(a1)
  191.     blt.s    .Move
  192.     clr.w    BOB_Frame(a1)
  193.     bra.s    .Move
  194.  
  195. .FireOn    cmp.w    #FIRESPEED,d7
  196.     ble.s    .Move
  197.     moveq    #$00,d7
  198.     cmp.w    #10,BOB_Frame(a1)
  199.     bge.s    .On
  200.     move.w    #9,BOB_Frame(a1)
  201.  
  202. .On    addq.w    #1,BOB_Frame(a1)
  203.     cmp.w    #13,BOB_Frame(a1)
  204.     blt.s    .Move
  205.     clr.w    BOB_Frame(a1)
  206.     clr.b    FireState
  207.     move.l    SND_Rambo(pc),a0
  208.     CALL    Activate
  209.  
  210. .Move    move.l    JoyData(pc),a0
  211.     CALL    Query
  212.     move.l    JoyData(pc),a0
  213.     move.l    BOB_Rambo(pc),a1
  214.     move.w    JD_XChange(a0),d0
  215.     add.w    d0,BOB_XCoord(a1)
  216.     move.w    JD_YChange(a0),d0
  217.     add.w    d0,BOB_YCoord(a1)
  218.     move.l    JD_Buttons(a0),d0
  219.     btst    #JB_LMB,d0
  220.     beq.s    .chkRMB
  221.     st    FireState    ;Set fire to on.
  222. .chkRMB    btst    #JB_RMB,d0
  223.     beq    .Loop
  224.     rts
  225.  
  226. FireState:
  227.     dc.b    0
  228.     even
  229.  
  230. ;===========================================================================;
  231. ;                                  DATA
  232. ;===========================================================================;
  233.  
  234. ObjectData:    dc.l  0
  235. JoyData:    dc.l  0
  236. Screen:        dc.l  0
  237. PIC_Background:    dc.l  0
  238. BackgroundFile:    FILENAME "GMS:demos/data/PIC.Green"
  239.  
  240. OBJFileName:    FILENAME "GMS:demos/data/OBJ.Worm"
  241.  
  242. Objects:    dc.l  OBJECTLIST,0
  243.         dc.l  TXT_Worm
  244. BOB_Rambo:    dc.l  0
  245.         dc.l  TXT_SNDRambo
  246. SND_Rambo:    dc.l  0
  247.         dc.l  LISTEND
  248.  
  249. TXT_Worm:    dc.b  "Worm",0
  250. TXT_BOBPicture:    dc.b  "BOBPicture",0
  251. TXT_SNDRambo:    dc.b  "SNDRambo",0
  252.         even
  253.  
  254. RestoreTags:    dc.l  TAGS_RESTORE
  255. Restore:    dc.l  0
  256.         dc.l  RSA_Entries,1
  257.         dc.l  TAGEND
  258.  
  259. ;---------------------------------------------------------------------------;
  260.  
  261. ObjModTags:    dc.l  TAGS_MODULE
  262. ObjModule:    dc.l  0
  263.         dc.l  MODA_Name,ObjName
  264.         dc.l  TAGEND
  265.  
  266. ObjName:    dc.b  "mod.objects",0
  267.         even
  268.  
  269. OBJBase:    dc.l  0
  270.  
  271. ;===========================================================================;
  272.  
  273. ProgName:    dc.b  "Rambo Worm",0
  274. ProgAuthor:    dc.b  "Paul Manias",0
  275. ProgDate:    dc.b  "February 1998",0
  276. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  277. ProgShort:    dc.b  "Simple demonstration.",0
  278.         even
  279.  
  280.